package com.zpf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName: SimpleQuartzApplication
 * @Description: 简单 Quartz 微服务，不支持分布式
 * @Autor: ZPF
 * @Date: 2021/1/13 17:03
 **/
@Slf4j
@SpringBootApplication
@ImportResource("applicationContext.xml")
public class SimpleQuartzApplication {

    @Value("${server.port}")
    private int port;
    @Value("${server.session.timeout}")
    private int sessionTimeout;

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
        factory.setPort(port);
        factory.setSessionTimeout(sessionTimeout, TimeUnit.SECONDS);
        return factory;
    }

    public static void main(String[] args) {
        SpringApplication.run(SimpleQuartzApplication.class, args);
        System.out.println("【简单Quartz微服务 】已启动.");
    }
}
